package com.cxria.springcloud.feigh.filter

import com.netflix.zuul.ZuulFilter
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component

@Component
class MyFilter extends ZuulFilter {

    static Logger log = LoggerFactory.getLogger(MyFilter.class)

    @Override
    String filterType() {
        'pre'
    }

    @Override
    int filterOrder() {
        0
    }

    @Override
    boolean shouldFilter() {
        true
    }

    @Override
    Object run() {
        /*def ctx = RequestContext.currentContext
        def request = ctx.getRequest()
        log.info(String.format('%s >>> %s', request.getMethod(), request.getRequestURI()))
        def accessToken = request.getParameter('token')
        if(!accessToken) {
            log.warn('token is empty')
            ctx.setSendZuulResponse(false)
            ctx.setResponseStatusCode(401)
            try {
                ctx.getResponse().getWriter().write('token is empty')
            }catch (e){
                e.printStackTrace()
            }
            return
        }
        log.info('ok')*/
    }
    
}
